package org.viettan.android.main.xml;

import java.io.IOException;

import org.viettan.android.main.model.Section;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import com.google.inject.Inject;

public class SectionXmlParser extends BaseXmlParser<Section> {

    @Inject
    SectionXmlParser() {
	super("section");
    }

    @Override
    protected void parseProperty(Section section, XmlPullParser parser)
	    throws XmlPullParserException, IOException {
	String tagName = parser.getName();
	if (tagName.equalsIgnoreCase("title")) {
	    section.setTitle(parser.nextText());
	} else if (tagName.equalsIgnoreCase("idsec")) {
	    section.setId(Integer.parseInt(parser.nextText()));
	}
    }

    @Override
    protected Section createEntity(XmlPullParser parser) {
	return new Section();
    }
}
